package cn.tedu.weibo.mapper;

import cn.tedu.weibo.vo.Weibo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WeiboMapper {

    @Insert("insert into weibo values(null,#{title},#{content},#{url},#{author},#{userId},#{created})")
    void insert(Weibo weibo);

    @Select("select id,title,author,url from weibo order by created desc")
    List<Weibo> select();

    @Select("select id,title,content,url from weibo where user_id = #{id}")
    List<Weibo> selectMy(Integer id);

    @Delete("delete from weibo where id=#{id}")
    void delete(int id);

    @Select("select id,title,content,url,author,created from weibo where id = #{id}")
    Weibo selectById(int id);

    @Select("select url from weibo where id = #{id}")
    String selectUrlById(int id);
}
